import $ from 'jquery';
import Button from './Button';

export default class ItalicButton extends Button{
    _init() {
        let result = super._init.call(this);
        if (this.editor.util.os.mac) {
            this.title = `${this.title} ( Cmd + i )`;
        } else {
            this.title = `${this.title} ( Ctrl + i )`;
            this.shortcut = 'ctrl+i';
        }
        return result;
    }
    _activeStatus() {
        let active;
        active = document.queryCommandState('italic') === true;
        this.setActive(active);
        return this.active;
    }
    command() {
        document.execCommand('italic');
        if (!this.editor.util.support.oninput) {
            this.editor.trigger('valuechanged');
        }
        return $(document).trigger('selectionchange');
    }
}
ItalicButton.prototype.name = 'italic';
ItalicButton.prototype.icon = 'italic';
ItalicButton.prototype.htmlTag = 'i';
ItalicButton.prototype.disableTag = 'pre';
ItalicButton.prototype.shortcut = 'cmd+i';